const mongoose = require("mongoose");
mongoose.pluralize(null); //去掉集合后面的s
const { Schema, model } = mongoose;
const versionKey = { versionKey: false };
const moment = require("moment");
moment.locale("zh-cn");
//用户账号表
const UserSchema = new Schema(
  {
    email: {
      type: String,
      unique: true,
      trim: true,
    },
    password: {
      type: String,
      select: false, //私密，不会返回给前端
      default: "", //默认值
    },
    uid: {
      type: String,
      unique: true,
      default: () => new Date().getTime(),
    },
    avatarUrl: {
      type: String,
      default:
        "https://lvyou-1332935562.cos.ap-nanjing.myqcloud.com/ceshi%2FIMG_0600.PNG",
    },
    nickname: {
      type: String,
      default: "用户",
      trim: true,
    },
    gender: {
      type: String,
      default: "男",
    },
    birthday: {
      type: String,
      default: "",
    },
    age: {
      type: String,
      default: "",
    },
    city: {
      type: String,
      default: "",
    },
    backdrop: {
      type: String,
      default:
        "https://lvyou-1332935562.cos.ap-nanjing.myqcloud.com/ceshi%2FIMG_0601.PNG",
    },
    my_tags: {
      type: Array,
      default: [],
    },
  },
  versionKey
);

module.exports = {
  modelUser: model("user", UserSchema),
};